package demo1;

/**
 * @Auther: 杨通通
 * @Date: 2024/10/21 23:46
 * @Description:
 */
public class waitnotify1 {

    public static void main(String[] args) throws InterruptedException {
        Object lock = new Object();

        new Thread(()->{
            synchronized (lock){

                try {
                    System.out.println("wait之前");
                    lock.wait();
                    System.out.println("wait之后");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
        }).start();
        Thread.sleep(1000);
        synchronized (lock){
            System.out.println("执行notify");
            lock.notify();
        }
    }
}